#include<vector>
#include<unordered_map>
using namespace std;

class Solution {
private:
    unordered_map<int,int>map;
    int n_rows, n_cols;
    int rem;
public:
    Solution(int n_rows, int n_cols):n_rows(n_rows), n_cols(n_cols), rem(n_rows* n_cols){

    }

    vector<int> flip() {
        int index = rand() % rem--;
        if (map.find(index) == map.end())
            map[index] = index;
        int x = map[index];
        if (map.find(rem) == map.end())
            map[rem] = rem;
        swap(map[index], map[rem]);
        return { x / n_cols ,x % n_cols };
    }

    void reset() {
        map.clear();
        rem = n_rows * n_cols;
    }
};

/**
 * Your Solution object will be instantiated and called as such:
 * Solution* obj = new Solution(n_rows, n_cols);
 * vector<int> param_1 = obj->flip();
 * obj->reset();
 */